<?php
namespace Admin\Controller;

use Util\AccessController;
/*
 * 有赞接口
 */
class BookCaseModelController extends AccessController {
    public function index(){
        $LS = Service('BookCaseModel','sj_model');
        $DATA = $LS->query();
        $this->DATA = $DATA;
        $this->display();
    }

    public function Add(){
        $DATA = $_POST;
        $DATA['BHCODE'] = 'SJM_' .uniqid();
        $LS = Service('BookCaseModel','sj_model');
        if($_POST['ID']){
            $where['ID'] = $_POST['ID'];
            $save = $_POST;
            $OK = $LS->update($where,$save);
        }else{
            $OK = $LS->insert($DATA);
        }
        $OK ? $this->success('添加/編輯成功'):$this->error('添加編輯失败');
    }

    public function Del(){
        $LS = Service('BookCaseModel','sj_model');
        $OK = $LS->remove($_GET);
        $OK ? $this->success('删除成功'):$this->error('删除失败');
    }
}